#include "workCmd.h"

int handleLongCmd(int netFd,int userId){
    printf("Long cmd!\n");
    char cmd[100] = {0};
    int dataLength = 0;
    recvn(netFd,&dataLength,sizeof(dataLength));
    recvn(netFd,cmd,dataLength);
    sysadd(userId,cmd);

    if(strncmp("puts",cmd,3) == 0){
        printf("Download \n");
        download(netFd,userId);
    }else{
        char file[100] = {0};
        int i = 4;
        while(cmd[i] == ' '){
            ++i;
        }
        strcpy(file,cmd + i);
        printf("Upload file %s.\n",file);
        upload(netFd,file,userId);
    }
    return 0;
}
